package com.hedl.practice.diyJava.genericity.utils;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;

public class Person implements Comparable<Person>{
    String name;
    int age;

    public Person(String name,int age){
        this.name = name;
        this.age = age;
    }

   /* public int compareTo(Person other){
        return this.name.compareTo(other.name);
    }*/

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }


    //按大小比较进行排序输出
    @Override
    public int compareTo(@NotNull Person o) {

        //return this.name.compareTo(o.name);
        //return o.age + o.age;
        /*if (this.age == o.age){
            return this.name.compareTo(o.name);
        }*/
        return -(this.age - o.age);
    }
}
